<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>编辑饮食记录</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 20px;
        }
        h1 {
            color: #4CAF50;
        }
        form {
            width: 50%;
            margin-top: 20px;
        }
        label {
            display: inline-block;
            width: 120px;
            margin: 10px 0;
            font-weight: bold;
        }
        input[type="text"],
        input[type="number"],
        input[type="datetime-local"],
        select {
            width: 200px;
            padding: 8px;
            margin: 5px 0;
            border: 1px solid #ddd;
            border-radius: 4px;
        }
        input[type="submit"] {
            background-color: #4CAF50;
            color: white;
            padding: 10px 20px;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            margin-top: 15px;
        }
        input[type="submit"]:hover {
            background-color: #45a049;
        }
        .form-group {
            margin-bottom: 15px;
        }
    </style>
</head>
<body>
<h1>编辑饮食记录</h1>

<form action="${pageContext.request.contextPath}/dietrecord/update" method="post">
    <input type="hidden" name="dietrecordid" value="${dietRecord.dietrecordid}">

    <div class="form-group">
        <label>用户:</label>
        <input type="text" name="userid" value="${dietRecord.user.userid}" readonly>
    </div>

    <div class="form-group">
        <label>食物:</label>
        <input type="text" name="recipeid" value="${dietRecord.foodsrecipe.recipeid}" required>
    </div>

    <div class="form-group">
        <label>用餐时间:</label>
        <select name="eattime">
            <option value="早餐" ${dietRecord.eattime == '早餐' ? 'selected' : ''}>早餐</option>
            <option value="中餐" ${dietRecord.eattime == '中餐' ? 'selected' : ''}>中餐</option>
            <option value="晚餐" ${dietRecord.eattime == '晚餐' ? 'selected' : ''}>晚餐</option>
            <option value="加餐" ${dietRecord.eattime == '加餐' ? 'selected' : ''}>加餐</option>
        </select>
    </div>

    <div class="form-group">
        <label>数量:</label>
        <input type="number" name="num" value="${dietRecord.num}" min="1" required>
    </div>

    <div class="form-group">
        <label>总热量:</label>
        <input type="number" name="totalcalories" value="${dietRecord.totalcalories}" min="0" required>
    </div>

    <div class="form-group">
        <label>创建时间:</label>
        <input type="datetime-local" name="createtime" required>
    </div>

    <input type="submit" value="保存修改">
</form>
</body>
</html>